package gameSocketer.socketSenders
{
	import com.adobe.serialization.json.JSON;

	public class CardGameSocketSender extends SocketSenderBase
	{
		public static var instance:CardGameSocketSender;
		
		public function CardGameSocketSender(key:Key)
		{
			super();
		}
		
		/**获取游戏逻辑socketer实例*/
		public static function getInstance():CardGameSocketSender
		{
			instance||=new CardGameSocketSender(new Key());
			return instance;
		}
		
		/**2.1 下注信息包*/
		public function chipOverPack(list:Array):void{
			sendData.writeByte(2);
			sendData.writeByte(1);
			
			tempObj = new Object();
			tempObj["list"] = list;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.2 补牌信息包*/
		public function addardPack(circleUnitID:int):void{
			sendData.writeByte(2);
			sendData.writeByte(2);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = circleUnitID;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.3 赌倍信息包*/
		public function doubleChipPack(circleUnitID:int):void{
			sendData.writeByte(2);
			sendData.writeByte(3);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = circleUnitID;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.5 分牌信息包*/
		public function separateCardPack(circleUnitID:int):void{
			sendData.writeByte(2);
			sendData.writeByte(5);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = circleUnitID;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.6 牌局结束信息包*/
		public function oneGameOverPack():void{
			sendData.writeByte(2);
			sendData.writeByte(6);
			
			socketer.send();
		}
		
//		/**2.8 保险信息包*/
//		public function insumePack(index:int):void{
//			sendData.writeByte(2);
//			sendData.writeByte(8);
//			
//			tempObj = new Object();
//			tempObj["circleUnitID"] = index;
//			
//			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
//			
//			socketer.send();
//		}
		
		/**2.9 停牌包*/
		public function stopCardPack(index:int):void{
			sendData.writeByte(2);
			sendData.writeByte(9);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = index;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.10 爆牌包*/
		public function boonCardPack(index:int):void{
			sendData.writeByte(2);
			sendData.writeByte(10);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = index;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			trace("发送爆牌包");
			socketer.send();
		}
		
		/**2.11 牌类型包*/
		public function cardNumPack(num:int):void{
			sendData.writeByte(2);
			sendData.writeByte(11);
			
//			tempObj = new Object();
//			tempObj["type"] = num;
//			
//			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.12 牌21点包*/
		public function point21Pack(index:int):void{
			sendData.writeByte(2);
			sendData.writeByte(12);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = index;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		/**2.13 牌点包*/
		public function pointPack(point:int,index:int):void{
			sendData.writeByte(2);
			sendData.writeByte(13);
			
			tempObj = new Object();
			tempObj["points"] = point;
			tempObj["circleUnitID"] = index;
			
			trace("告知服务器点数包索引为：",index," 点数：",point);
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.14 所有不买保险包*/
		public function allNoInsumePack():void{
			sendData.writeByte(2);
			sendData.writeByte(14);
			
			socketer.send();
		}
		
		/**2.15 单个玩家买保险包*/
		public function insumePack(index:int):void{
			sendData.writeByte(2);
			sendData.writeByte(15);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = index;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.16 所有玩家买保险包*/
		public function allInsumePack():void{
			sendData.writeByte(2);
			sendData.writeByte(16);
			
			socketer.send();
		}
		
		/**2.17 单个玩家不买保险包*/
		public function noInsumePack(index:int):void{
			sendData.writeByte(2);
			sendData.writeByte(17);
			
			tempObj = new Object();
			tempObj["circleUnitID"] = index;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.18 保险处理完毕包*/
		public function oneIsumeOverPack(list:Array):void{
			sendData.writeByte(2);
			sendData.writeByte(18);
			
			tempObj = new Object();
			tempObj["list"] = list;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
		
		/**2.19 剩余不买保险包*/
		public function elseNoInsumePack():void{
			sendData.writeByte(2);
			sendData.writeByte(19);
			
			socketer.send();
		}
	}
}
class Key{};